cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(NetFileTransfer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTORCC TRUE)
set(CMAKE_AUTOUIC TRUE)

if (MSVC)
    #    vs2017 or later
    if (${MSVC_VERSION} LESS 1910)
        message(FATAL_ERROR "Please use VS 15.0 (v141 toolset) or later")
        return()
    endif ()

    if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
        add_compile_options(/utf-8 /EHsc /MP /ZI)
        add_link_options(/SUBSYSTEM:CONSOLE /INCREMENTAL)
    else()
        add_compile_options(/utf-8 /EHsc /MP)
    endif ()
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    enable_language("RC")
    set(WIN32_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resource/net-file-transfer.rc)
    set(GUI_TYPE WIN32)
endif ()


set(REQUIRED_QT_MODULES Core Gui Widgets Svg Network LinguistTools)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
# 判断Qt版本是否大于6
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
    set(REQUIRED_QT_MODULES ${REQUIRED_QT_MODULES} Core5Compat)
endif()
find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED COMPONENTS ${REQUIRED_QT_MODULES})

# where to find our CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(QtPacking)
include_directories(thirdpart)
add_subdirectory(src)
